package com.hzlx.data.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.hzlx.data.domain.EquipmentRealtimeData;
import com.hzlx.data.service.IEquipmentRealtimeDataService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 设备实时运行状态与关键指标Controller
 * 
 * @author ruoyi
 * @date 2025-06-30
 */
@RestController
@RequestMapping("/equipment")
public class EquipmentRealtimeDataController extends BaseController
{
    @Autowired
    private IEquipmentRealtimeDataService equipmentRealtimeDataService;

    /**
     * 查询设备实时运行状态与关键指标列表
     */
    @RequiresPermissions("equipment-service:realtimeData:list")
    @GetMapping("/realtimeData/list")
    public TableDataInfo list(EquipmentRealtimeData equipmentRealtimeData)
    {
        startPage();
        List<EquipmentRealtimeData> list = equipmentRealtimeDataService.selectEquipmentRealtimeDataList(equipmentRealtimeData);
        return getDataTable(list);
    }

    /**
     * 导出设备实时运行状态与关键指标列表
     */
    @RequiresPermissions("equipment-service:realtimeData:export")
    @Log(title = "设备实时运行状态与关键指标", businessType = BusinessType.EXPORT)
    @PostMapping("/realtimeData/export")
    public void export(HttpServletResponse response, EquipmentRealtimeData equipmentRealtimeData)
    {
        List<EquipmentRealtimeData> list = equipmentRealtimeDataService.selectEquipmentRealtimeDataList(equipmentRealtimeData);
        ExcelUtil<EquipmentRealtimeData> util = new ExcelUtil<EquipmentRealtimeData>(EquipmentRealtimeData.class);
        util.exportExcel(response, list, "设备实时运行状态与关键指标数据");
    }

    /**
     * 获取设备实时运行状态与关键指标详细信息
     */
    @RequiresPermissions("equipment-service:realtimeData:query")
    @GetMapping(value = "/realtimeData/{dataId}")
    public AjaxResult getInfo(@PathVariable("dataId") Long dataId)
    {
        return success(equipmentRealtimeDataService.selectEquipmentRealtimeDataByDataId(dataId));
    }

    /**
     * 新增设备实时运行状态与关键指标
     */
    @RequiresPermissions("equipment-service:realtimeData:add")
    @Log(title = "设备实时运行状态与关键指标", businessType = BusinessType.INSERT)
    @PostMapping("/realtimeData")
    public AjaxResult add(@RequestBody EquipmentRealtimeData equipmentRealtimeData)
    {
        return toAjax(equipmentRealtimeDataService.insertEquipmentRealtimeData(equipmentRealtimeData));
    }

    /**
     * 修改设备实时运行状态与关键指标
     */
    @RequiresPermissions("equipment-service:realtimeData:edit")
    @Log(title = "设备实时运行状态与关键指标", businessType = BusinessType.UPDATE)
    @PutMapping("/realtimeData")
    public AjaxResult edit(@RequestBody EquipmentRealtimeData equipmentRealtimeData)
    {
        return toAjax(equipmentRealtimeDataService.updateEquipmentRealtimeData(equipmentRealtimeData));
    }

    /**
     * 删除设备实时运行状态与关键指标
     */
    @RequiresPermissions("equipment-service:realtimeData:remove")
    @Log(title = "设备实时运行状态与关键指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/realtimeData/{dataIds}")
    public AjaxResult remove(@PathVariable Long[] dataIds)
    {
        return toAjax(equipmentRealtimeDataService.deleteEquipmentRealtimeDataByDataIds(dataIds));
    }
}
